<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div{
      background-color: pink;
    }
    .t1{
      width: 100px;
      height: 100px;
    }
    .t2{
      width: 300px;
      height: 300px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%,-50%);
    }
  </style>
</head>
<body>
  <input type="button" value="按钮" id="btn">
  <div id="di" class="t1"></div>
  <script>
    var btn =document.getElementById("btn");
    var di = document.getElementById("di")
    var li = 1;
    btn.onclick = function () {
      if (li === 1) {
        di.classList.add("t2");
        di.classList.remove("t1");
        li = 2;
      }else{
        di.classList.add("t1");
        di.classList.remove("t2");
        li = 1;
      }
    }
  </script>
</body>
</html>